package com.heu.blood.storge.controller;

import java.util.Arrays;
import java.util.Map;


import com.heu.blood.common.aop.ControllerLogAnnotation;
import com.heu.blood.storge.vo.BloodScrapEntityVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.heu.blood.storge.entity.BloodScrapEntity;
import com.heu.blood.storge.service.BloodScrapService;
import com.heu.blood.common.utils.PageUtils;
import com.heu.blood.common.utils.R;



/**
 * 血液报废表
 *
 * @author lhh
 * @email lhh1612325771@163.com
 * @date 2024-07-07 16:23:52
 */
@RestController
@RequestMapping("storge/bloodscrap")
public class BloodScrapController {
    @Autowired
    private BloodScrapService bloodScrapService;

    /**
     * 列表
     */
    @RequestMapping("/queryPage")
    @ControllerLogAnnotation(module = "血液报废", operate = "分页查询血液报废信息")
    public R queryPage(@RequestBody BloodScrapEntityVo bloodScrapEntityVo){
        PageUtils page = bloodScrapService.queryPage(bloodScrapEntityVo);

        return R.ok().put("page", page);
    }

    @RequestMapping("/scrap")
    @ControllerLogAnnotation(module = "血液报废", operate = "执行血液报废")
    public R scrap(@RequestBody BloodScrapEntityVo bloodScrapEntityVo){
        boolean b = bloodScrapService.scrap(bloodScrapEntityVo);
        if (b) {
            return R.ok("报废成功");
        }
        return R.ok("不存在的BloodID或者状态已经为报废\n");
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ControllerLogAnnotation(module = "血液报废", operate = "根据ID查询血液报废信息")
    public R info(@PathVariable("id") Long id){
		BloodScrapEntity bloodScrap = bloodScrapService.getById(id);

        return R.ok().put("bloodScrap", bloodScrap);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ControllerLogAnnotation(module = "血液报废", operate = "保存血液报废信息")
    public R save(@RequestBody BloodScrapEntity bloodScrap){
		bloodScrapService.save(bloodScrap);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ControllerLogAnnotation(module = "血液报废", operate = "修改血液报废信息")
    public R update(@RequestBody BloodScrapEntity bloodScrap){
		bloodScrapService.updateById(bloodScrap);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ControllerLogAnnotation(module = "血液报废", operate = "删除血液报废信息")
    public R delete(@RequestBody Long[] ids){
		bloodScrapService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
